package chapter5;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description: 找出一个整数的因子
 * Date:2021/4/3
 * ***************************************************************
 */
public class exc5_16 {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		System.out.print("Enter an integer:  ");
		int number=input.nextInt();
		//灵活使用for语句，for语句条件不用补全
		for(int i=2;;) {
			if(number%i==0) {
				number/=i;
				System.out.print(i+" ");
				if(number==1) {
					break;
				}
			}else {
				i++;
			}
			
		}
		
		/*上方代码可读性稍差
		 * 
		 * while(number!=1)
        {
            for(int i=2;i<=number;i++)
            {
                if(number%i==0)
                {
                    number=number/i;
                    System.out.print(i+" ");
                    break;
                }
            }
        }
		 * 
		 * 
		 * */
		
	}

}
